home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / System 7.0 Samples / AEObject-Edition1.0.2 Sample / Structs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-18  |  8.2 KB  |  251 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2.  *
  3.  *  Apple Developer Technical Support
  4.  *
  5.  *  Text section handling routines
  6.  *
  7.  *  Program:    AEObject-Edition Sample
  8.  *  File:       AESampStructs.h -    C Source
  9.  *
  10.  *  by:         C.K. Haun <TR>
  11.  *
  12.  *  Copyright © 1990-1992 Apple Computer, Inc.
  13.  *  All rights reserved.
  14.  *
  15.  *------------------------------------------------------------------------------
  16.  * This file contains all the structure definitions for the structs I use
  17.  * in this sample
  18. *----------------------------------------------------------------------------*/
  19.  
  20.  
  21. #ifndef __STRUCTS__
  22. #define __STRUCTS__
  23. /* Structures */
  24. struct myLine {                /* my own structure for defining a line */
  25.     Point start;
  26.     Point end;
  27. };
  28. typedef struct myLine myLine, *myLinePtr, **myLineHandle;
  29. /* my text section (pub or sub) structure.  I will probably make this  */
  30. /* a struct for all my editions soon. */
  31. struct textSection {
  32.     struct textSection **nextSection;
  33.     Boolean publishing;  /* I don't really need to include this flag, but I would */
  34.                         /* rather do it here than dereferencing the section handle */
  35.                         /* all the time, makes the code a little more readable */
  36.     Boolean bordered;  /* this section should currently be bordered */
  37.     short startChar;
  38.     short endChar;
  39.     Handle    theText;
  40.     SectionHandle theSection;
  41.     unsigned long theID;
  42. };
  43. typedef struct textSection textSection, *textSectionPtr, **textSectionHandle;
  44.  
  45. /* Instead of using the handles I've used in the window structure, a */
  46. /* section list like this may be more helpful, particularly if you */
  47. /* will be working with a great many sections */
  48. struct mySectionData {
  49.     struct mySectionData **nextSection;
  50.     Boolean publishing;
  51.     Boolean bordered;
  52.     SectionHandle theSection;
  53.     Rect theRect;
  54.     short startChar;
  55.     short endChar;
  56.     Handle additionalData;
  57.     unsigned long theID;
  58. };
  59. typedef struct mySectionData mySectionData, *mySectionDataPtr,**mySectionDataHandle;
  60.  
  61.  
  62.  
  63. /* structure for the graphic elements in a document window */
  64. struct Shapes{
  65. short type;    /* what kind is this? */
  66. DescType aeType;
  67. Rect theRect;    /* what's it's rectangle? */
  68.  struct Shapes **nextShape;
  69. long shapeIndex;
  70. RGBColor theColor;    
  71. };
  72. typedef struct Shapes Shapes;
  73. typedef Shapes *ShapesPtr,**ShapesHandle;
  74.  
  75.  
  76. /* windowControl is the structure attached to every window I create (in the refCon */
  77. /* field) that contains all the information I need to know about the window. */
  78. /* data, procedure pointers for controlling, and anything else gets put in this */
  79. /* struct.  That makes my windows autonomous, almost object-like */
  80. struct windowControl {
  81.     unsigned long windowID;                                 /* master ID number for section recording */
  82.     ProcPtr drawMe;                                         /* content drawing procedure pointer */
  83.     ProcPtr clickMe;                                        /* content click routine */
  84.     ProcPtr saveMe;                                         /* document save procedure pointer */
  85.     ProcPtr closeMe;                                        /* document close procedure pointer */
  86.     ProcPtr sizeMe;
  87.     AliasHandle fileAliasHandle;                            /* alias for this document */
  88.     ShapesHandle theShapes;                                    /* list of shapes for this document */
  89.     unsigned short numShapes;                                /* so I can save a number in the file */
  90.     Rect selectionRect;                                     /* currently selected area in document */
  91.     Boolean hasSelection;                                   /* is there a selection? */
  92.     short currentAction;                                    /* what mode is document in */
  93.     short undoAction;                                       /* last completed action */
  94.     Boolean windowDirty;
  95.     mySectionDataHandle graphicSections;    
  96.     short numPubs;                                          /* count of active publishers */
  97.     Handle pubs;                                            /* handle containing section handles for publishers */
  98.     Handle pubRects;                                        /* where in the document the publisher is */
  99.     short numSubs;                                          /* count of active subscribers */
  100.     Handle subs;                                            /* handle containing section handles for subscribers */
  101.     Handle subRects;                                        /* where in the document the subscriber is */
  102.     Handle subDataHandle;                                   /* PICT data handles for each subscriber */
  103.     short numPicts;                                         /* number of non-sub PICTS */
  104.     Handle pictHandle;                                      /* handle to pic handles. This is needed when a user */
  105.     /* cancels a subscription, move the PICT to here */
  106.     Handle pictRects;                                       /* where in the document the subscriber is */
  107.     mySectionDataHandle textSections;
  108.     Rect textBox;
  109.     TEHandle boxHandle;
  110.     long windowIndex;                                        /* for AppleEvent information */
  111.  
  112. };
  113. typedef struct windowControl windowControl, *windowCPtr, **windowCHandle;
  114.  
  115.  
  116. /* A handy structure used to install AppleEvent handlers */
  117. struct AEinstalls{
  118.     AEEventClass theClass;
  119.     AEEventID    theEvent;
  120.     AEEventHandlerUPP    theProc;
  121. };
  122. typedef struct AEinstalls AEinstalls;
  123.  
  124. /* Ditto for coercion handlers */
  125. struct CoercionInstalls{
  126.     DescType fromType;
  127.     DescType toType;
  128.     AECoercionHandlerUPP    theProc;
  129.     Boolean isDesc;  /* will usually be FALSE, System coercion */
  130. };
  131. typedef struct CoercionInstalls CoercionInstalls;
  132.  
  133. /* Here are the structures I am using to define the type of  */
  134. /* object you want acted upon by an event.  Probably not very useful */
  135. /* outside of this sample */
  136. struct WindowObjectDef {
  137. DescType form;
  138. union {
  139. Str63 name;
  140. long index;
  141. } u;
  142. };
  143. typedef struct WindowObjectDef WindowObjectDef, *WindowObjectDefPtr, **WindowObjectDefHandle;
  144. struct TextObjectDef {
  145. DescType form;
  146. union {
  147. Str63 name;
  148. long index;
  149. } u;
  150. Boolean andWord;
  151. long wordNumber;
  152. };
  153. typedef struct TextObjectDef TextObjectDef, *TextObjectDefPtr, **TextObjectDefHandle;
  154.  
  155. struct ShapeObjectDef {
  156. short type;
  157. DescType form;
  158. union {
  159. Str63 name;
  160. long index;
  161. } u;
  162.  
  163. };
  164. typedef struct ShapeObjectDef ShapeObjectDef, *ShapeObjectDefPtr, **ShapeObjectDefHandle;
  165.  
  166.  
  167. /* Here are the structures that define my Tokens, that I pass */
  168. /* back and hand around during AEResolve */
  169. /* All these things are designed to give me all the info I */
  170. /* need to take an event action on an object */
  171. /* I didn't create a structure for my window token, since it's so simple */
  172. /* (just the window pointer) */
  173.  
  174. /* structure of my cText token */
  175. struct CTextObject {
  176. TEHandle theText;
  177. WindowPtr theOwningWindow;
  178. };
  179. typedef struct CTextObject CTextObject, *CTextObjPtr,**CTextObjHandle;
  180.  
  181. /* my word token */
  182. struct CWordObject {
  183. TEHandle theText;    /* need this for setting data */
  184. WindowPtr theOwningWindow;
  185. long startPos;
  186. long endPos;
  187. };
  188. typedef struct CWordObject CWordObject, *CWordObjPtr,**CWordObjHandle;
  189. /* structure of my cGraphicShape token */
  190. struct CShapeObject {
  191. WindowPtr theOwningWindow;
  192. ShapesHandle theShape;
  193. long shapeNumber;
  194. DescType type;
  195. };
  196. typedef struct CShapeObject CShapeObject, *CShapeObjPtr,**CShapeObjHandle;
  197.  
  198. /* structure of my Property token */
  199. struct PropertyToken {
  200. DescType owningTokenType;
  201. WindowPtr inWindow;
  202. union {
  203. ShapesHandle shapeHandle;
  204. TEHandle textHandle;
  205. WindowPtr window;
  206. } token;
  207. DescType theProperty;
  208. DescType theDataType;
  209. Handle theData;
  210. };
  211. typedef struct PropertyToken PropertyToken, *PropertyTPtr,**PropertyTHdl;
  212.  
  213.  
  214. /* My preferences structure */
  215. struct prefStruct {
  216. long version;
  217. Boolean prefsChanged;
  218. Boolean bringAEUp;
  219. Boolean verboseAE;
  220. Boolean saveWindDef;
  221. WindowObjectDef savedWOD;
  222. Boolean saveTextDef;
  223. TextObjectDef savedTOD;
  224. Boolean saveShapeDef;
  225. ShapeObjectDef savedSOD;
  226. Boolean saveInteract;
  227. short localInteraction;
  228. short sendInteraction;
  229. Boolean layerSwitch;
  230. Boolean saveTarget;
  231. short targetMode;
  232. Boolean saveReply;
  233. short replyMode;
  234. };
  235. typedef struct prefStruct prefStruct, *prefStructPtr, **prefStructHandle;
  236.  
  237. /* I thought about making this a union, but I use it so infrequently I didn't want it to get confusing */
  238. struct NewElementData{
  239. Rect theRect;
  240. long long1;
  241. long long2;
  242. Str63 name;
  243. };
  244. typedef struct NewElementData NewElementData,*NewElementDataPtr,**NewElementDataHdl;
  245.  
  246.  
  247. /* for passing back intl text information */
  248. typedef WritingCode *WritingCodePtr, **WritingCodeHdl;
  249.  
  250.  
  251. #endif